package ru.ksu.ktk.diploma.sdi.mapping.thesauri;

import com.hp.hpl.jena.ontology.Individual;
import com.hp.hpl.jena.ontology.OntClass;
import com.hp.hpl.jena.ontology.OntModel;

/**
 * Adapter for thesauri model
 * 
 * @author coldflame
 */
public class Thesauri {
    private OntModel model;
    private String baseNamespace;
    /**
     * language of thesauri (f.e. "ru")
     */
    private String language;

    public Thesauri(String baseNamespace, String language) {
        this.language = language;
        this.baseNamespace = baseNamespace;
    }

    public Individual getBaseIndividual(String descriptorName) {
        if (model == null) throw new IllegalStateException("thesauri model is null");
        if (baseNamespace == null) throw new IllegalStateException("base namespace is null");
        if (descriptorName == null) throw new IllegalArgumentException("descriptor name cannot be null");
        return model.getIndividual(baseNamespace + descriptorName);
    }

    public OntClass getOntClass(Individual individual) {
        if (model == null) throw new IllegalStateException("thesauri model is null");
        return model.getOntClass(individual.getRDFType(true).getURI());
    }

    public OntModel getModel() {
        return model;
    }

    public void setModel(OntModel model) {
        this.model = model;
    }

    public String getBaseNamespace() {
        return baseNamespace;
    }

    public void setBaseNamespace(String baseNamespace) {
        this.baseNamespace = baseNamespace;
    }

    public String getLanguage() {
        return language;
    }

    public void setLanguage(String language) {
        this.language = language;
    }

}
